#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
		if (nums.size() == 1)
			return nums[0];
		vector<int> iv(nums.size() + 1, nums[0]);
		//iv[0] = nums[0];
		for (int i = 1; i < nums.size(); ++i)			
			iv[i] = max(iv[i - 1] + nums[i], nums[i]);
		return *max_element(iv.begin(), iv.end());
    }
};
int main()
{
	vector<int> iv{ 1 };
	cout << Solution().maxSubArray(iv);

}